<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="include :: header"></head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">

            <div class="ibox-content">
                <div id="agentTree"></div>
            </div>
            <div class="form-group hidden">
                <div class="col-sm-12 col-sm-offset-12">
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>


<script type="text/javascript">
    $(document).ready(function() {
        getTreeData()
    });
    function getTreeData() {
        $.ajax({
            type : "GET",
            url : "/pay/agent/tree",
            success : function(tree) {
                loadTree(tree);
            }
        });
    }
    function loadTree(tree) {
        $('#agentTree').jstree({
            'core' : {
                'data' : tree
            },
            "plugins" : [ "search" ]
        });
        $('#agentTree').jstree().open_all();
    }
    $('#agentTree').on("changed.jstree", function(e, data) {
        if(data.node.id!=-1){
            parent.loadAgent(data.node.id,data.node.text);
            var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
            parent.layer.close(index);
        }

    });

</script>
</body>

</html>
